LEN block

Short summary

Name

LEN

→POU type

→function

Category

Standard (non-safe), String

Conform to →IEC-standard

(error) currently restricted
(IEC demands data type ANY_STRING for the input, hence the following data type is demanded as well: WSTRING. Currently, this data type is not supported for the block.) 

Graphical interface

Available since

version 1.30.0 (for Neuron Power Engineer) - initial variant

version 3.8.0 (for library Standard (non-safe)): block moved in this library

Functionality

The block determines the length of a string.

At input IN, enter the string for which the length should be determined.

(info) Neuron Power Engineer  determines the character positions within a string as follows: 12, ..., n. 1 corresponds to the leftmost character position and n to the length of the string.
Three-character combination of the dollar sign ($) followed by two hexadecimal digits are evaluated as single character. Example: The string '$B15' (corresponds to '±5') consists of 2 characters. See →character string literal for more examples for those combinations. 

Inputs, return value

 

Identifier

→Data type

Description

Inputs:

IN

STRING

input value

Return value:

USINTUINTUDINTULINTSINTINTDINT or LINT
(corresponds to →generic data type ANY_INT

 

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

See:

Example for usage within ST-editor

PROGRAM Test
    VAR
        result1, result2, result3, result4 : INT;
    END_VAR
    result1 := LEN(IN := 'ASTRING');       (* The variable 'result' evaluates to '7'. *)
    result2 := LEN(IN := '$B15');          (* The variable 'result' evaluates to '2'. *)
    result3 := LEN(IN := 'ABC$00D');       (* The variable 'result' evaluates to '3'. Reason: The character string is terminated at position 4 because of '$00'. *)
    result4 := LEN(IN := '');              (* The variable 'result' evaluates to '0'. *)
END_PROGRAM

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.